1. Field of the Invention
The present invention relates to an image processing apparatus that compresses document images and an image encoding method, and more particularly to an image processing apparatus that compresses a document image including a non-photo image and an image encoding method.
2. Description of the Related Art
Along with the recent digitization of information, rather than storing paper documents, systems are becoming widely available that digitize information through scanning using a scanner or the like, and transmit/receive the electronic data to/from other apparatuses. In order to reduce the cost required for transmission and reception, compressing digitized documents at high ratios is in demand. At the same time, reusability, which is the ability to partially edit the digitized data, as well as the ability to achieve high image quality while preventing degradation of the image quality even when images are enlarged or reduced are also in demand.
However, when a document image including both a character region and a photo image region is compressed at a compression ratio suitable for the character region (e.g., lossless compression), a problem arises in that although the image quality after decoding is good, the compression ratio is low. On the other hand, when the document image is compressed at a compression ratio suitable for the photo image region (e.g., lossy compression such as JPEG), a problem arises in that although a high compression ratio is achieved, the quality of decoded characters is poor. To address this, for example, Japanese Patent Laid-Open Nos. 2002-077633 and 2005-012768 propose techniques in which a character region is extracted from a document image, and the image of the character region is compressed with a character compression scheme (MMR etc.) whereas the base portion after the character region has been extracted is filled and compressed with a compression scheme (JPEG) suitable for photos and the like. As the filling method, for example, techniques have been proposed such as a technique in which the character region is filled with the average color of the surrounding pixels, and a technique in which the character region is filled with a color determined in accordance with the histogram information of the character region.
Japanese Patent Laid-Open No. 2004-265384 proposes a technique for achieving a high compression ratio, reusability and high image quality by separating a digitized document image into a character region and a photo image region, converting the character region or the like, for which reusability and high image quality are required, into vector data, compressing the photo image region or the like, which cannot be reproduced easily with vector data, into JPEG format, synthesizing the vectorized result of the character region and the JPEG compression result of the photo image region, and outputting the synthesized result. Specifically, region separation is first performed on the document image to identify the character region and the line drawing region as rectangular regions. Then, character objects and line drawings that can be vectorized are vectorized, and the obtained vector data is stored in a vector layer. Regions that are not vectorized and image regions where the vectorized character region have been filled are compressed in the JPEG format, and the obtained JPEG data is stored in a JPEG layer. These vector layer data and the JPEG layer data are stored as a compressed document file.
In order to improve high compression performance, reusability, and high image quality performance for document images, Japanese Patent Laid-Open No. 2006-344069 proposes a technique with which a target to be vectorized is enlarged, and non-photo images such as illustrations, which have hitherto been compressed in the JPEG format as is the case with photos, are vectorized. The non-photo images are also called as “illustrations” or “clip art images”, and they have features such as clear outline of an object, and a limited number of colors appearing therein. The term “non-photo image” used herein may be construed as including a character and a line drawing. However, it should be understood that, in the case of a configuration in which an image region from which a character region and a line drawing region have been separated is further separated into a photo image region and a non-photo image region, the image region includes no characters and line drawings at the point in time when it is separated into a photo image region and a non-photo image region.
Furthermore, photo image regions are often placed as rectangular images in document images, whereas compared to photo image regions, non-photo image regions, such as illustrations, are more often drawn as images with shapes other than a rectangle. In addition, when the region separation process is performed for an image, the range of regions such as a character region and graphic region is defined by a circumscribed rectangle, so it is often the case that an illustration region includes another image in addition to the illustration itself, such as the background.
When a rectangular illustration region (clip art region) is vectorized using the technique of Japanese Patent Laid-Open No. 2006-344069, the background portion is treated in the same manner as illustrations and is vectorized as a single-color region with the average color of the background portion as a representative color. However, in such an illustration region, a situation can occur in which the background portion outside the illustration portion has subtle color gradation, rather than a single color. The “subtle color gradation” used herein means color gradation that actually varies slightly although it is determined as having a single color when clustered in colors. For example, a graphic region 34 shown in FIG. 22 includes illustration images (circular image portions) and a background region with subtle color gradation. When color clustering is performed on the graphic region 34, the illustrations are clustered in colors, and at the same time, the background portion is also extracted as a single region, and the representative color of the background portion is also calculated in the same manner as the illustrations. Specifically, when the background portion with such color gradation is treated as having a single color, the difference from the original image increases, causing a strong sense of discomfort. Accordingly, it is actually desired to allow the background with subtle color gradation to remain as original, rather than subjecting the background portion to the same process as the illustrations and treating it as having a single color.
Also, in a document image including a non-photo image region, a situation can occur in which the document image includes a non-photo image region (namely, a rectangular non-photo image region 33 as shown in FIG. 15) and a photo image region 31 overlapping the non-photo image region, or in other words, when the photo image region is overlapping the background portion outside the illustration. In the case of such an image, first, the non-photo image region (illustration region) is extracted, and the extracted non-photo image region is vectorized. On the other hand, in the document image from which the non-photo image region has been extracted, a region corresponding to the non-photo image region is filled and compressed in the JPEG format. In this case, a problem arises in that part of the photo image region overlapping the non-photo image region disappears as shown in FIG. 17 because the whole non-photo image region is filled, making it impossible to reproduce the original image.